﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
///Hotel 的摘要说明
/// </summary>
public class Hotel : Component
{

    Component mComponent;
    string hotelID="";

    string province = "";
    string city = "";
    string county = "";

    string name = "";
    string provinceID = "";
    string cityID = "";
    string countyID = "";
    string address = "";





    public string CityID
    {
        get { return cityID; }
        set { cityID = value; }
    }

    public string CountyID
    {
        get { return countyID; }
        set { countyID = value; }
    }

    public string ProvinceID
    {
        get { return provinceID; }
        set { provinceID = value; }
    }

    public string HotelID
    {
        get { return hotelID; }
        set { hotelID = value; }
    }
   

    public string Name
    {
        get { return name; }
        set { name = value; }
    }
   

    public string Province
    {
        get { return province; }
        set { province = value; }
    }
    

    public string City
    {
        get { return city; }
        set { city = value; }
    }
    

    public string County
    {
        get { return county; }
        set { county = value; }
    }
    

    public string Address
    {
        get { return address; }
        set { address = value; }
    }
    string telephonenumber = "";

    public string Telephonenumber
    {
        get { return telephonenumber; }
        set { telephonenumber = value; }
    }


	public Hotel()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    public Hotel(
       Component mComponent)
    {
        this.mComponent = mComponent;
    }
    public Hotel(
        string name,
        string provinceID,
        string cityID,
        string countyID,
        string address,
        string telephonenumber
    )
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //

        this.name = name;
        this.provinceID = provinceID;
        this.cityID = cityID;
        this.countyID = countyID;
        this.address = address;
        this.telephonenumber = telephonenumber;
    }
    public Hotel(
        Component mComponent,
        string name ,
        string provinceID ,
        string cityID ,
        string countyID ,
        string address ,
        string telephonenumber
    )
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //

        this.mComponent = mComponent;
        this.name = name;
        this.provinceID = provinceID;
        this.cityID = cityID;
        this.countyID = countyID;
        this.address = address;
        this.telephonenumber = telephonenumber;
    }


    public override string insert(System.Data.SqlClient.SqlConnection sqlcon)
    {
        throw new NotImplementedException();
    }


    public static bool isExist(SqlConnection sqlcon, string mHotelName,string mProvinceId,string mCityId,string mCountyId)
    {

        try
        {
            string sqlcmd = " SELECT * FROM Hotel WHERE hotelname=" + SqlFormat.ap(mHotelName)
            + "and ProID=" + SqlFormat.ap(mProvinceId)
            + "and CityID=" + SqlFormat.ap(mCityId)
            + "and CountyId=" + SqlFormat.ap(mCountyId)
            + ";";
            SqlDataAdapter sqladt = new SqlDataAdapter();
            DataTable dts = new DataTable();
            sqladt.SelectCommand = new SqlCommand(sqlcmd, sqlcon);
            sqladt.Fill(dts);

            if (dts.Rows.Count != 1)
            {
                return false;
            }

            return true;
        }
        catch (System.Exception ex)
        {
            
        	return false;
        }
        
    }
}